﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShevaEngine.Core.Modules.Scenes;
using Microsoft.Xna.Framework;

namespace ShevaEngine.Core.Modules.Animations
{
    /// <summary>
    /// Attach to animation bridge.
    /// </summary>
    public class AttachToAnimationBridge : SceneObject
    {
        /// <summary>Scene world.</summary>
        private Matrix _AnimationWorld;
        /// <summary>Scene world.</summary>
        public Matrix AnimationWorld
        {
            get { return this._AnimationWorld; }
            set
            {
                this._AnimationWorld = value;

                this.SceneObject.Transform(this._AnimationWorld * this.World);
            }
        }
        /// <summary>Scene object.</summary>
        private SceneObject SceneObject;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sceneObject"></param>
        public AttachToAnimationBridge(SceneObject sceneObject)
        {
            this.SceneObject = sceneObject;            
        }

        /// <summary>
        /// Method overrides Transform.
        /// </summary>
        /// <param name="matrix"></param>
        public override void Transform(Matrix matrix)
        {
            base.Transform(matrix);

            this.SceneObject.World = this._AnimationWorld * this.World;
        }
    }
}
